package web.tcp;

import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

/**
 * @description
 * @className ClientDemo
 * @package web.tcp
 * @author dongww@hsyuntai.com
 * @date 2020/3/11 14:03
 * @copyright 版权归 HSYUNTAI 所有
 */
public class ClientDemo {

    public static void main(String[] args) throws UnknownHostException, IOException {

        // 创建一个套接字并将其连接到指定端口号
        Socket socket = new Socket(InetAddress.getLocalHost(), 999);

        OutputStream outputStream = socket.getOutputStream();

        outputStream.write("this is a test".getBytes());

        outputStream.close();
    }
}